package com.ewanghuiju.app.widget.popupwindow;

import android.app.Activity;
import android.content.Context;
import android.graphics.Paint;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ewanghuiju.app.R;
import com.ewanghuiju.app.component.ImageLoader;
import com.ewanghuiju.app.model.bean.response.PintuanShopListResponBean;
import com.makeramen.roundedimageview.RoundedImageView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import me.jessyan.autosize.AutoSize;
import razerdp.basepopup.BasePopupWindow;

/**
 * @author sj  qq:751943509
 * @class 成为团长弹框
 * @time 2020/2/19
 */
public class ToGroupleadPopup extends BasePopupWindow {

    @BindView(R.id.popup_title)
    TextView popupTitle;
    @BindView(R.id.popup_now_price)
    TextView popupNowPrice;
    @BindView(R.id.popup_yuan_price)
    TextView popupYuanPrice;
    @BindView(R.id.popup_num)
    TextView popupNum;
    @BindView(R.id.popup_close)
    ImageView popupClose;
    @BindView(R.id.popup_togroup_lead)
    TextView popupTogroupLead;
    @BindView(R.id.iv_shop_image)
    RoundedImageView ivShopImage;

    private PopupItemClickCallback mPopupItemClickCallback;


//    PintuanBuyCantuanPopup pintuanBuyCantuanPopup;

    public ToGroupleadPopup(Context context) {
        super(context);
        setWidth(getScreenWidth());
        ButterKnife.bind(this, getContentView());
    }

    @Override
    public View onCreateContentView() {
        return createPopupById(R.layout.popup_to_group_lead);
    }

    @OnClick({R.id.popup_close, R.id.popup_togroup_lead})
    public void doClick(View view) {
        int id = view.getId();
        switch (id) {
            case R.id.popup_close:
                dismiss();
                break;
            case R.id.popup_togroup_lead:
                //成为团长
//                if(isChange){
//                    isChange= false;
//                    popupTogroupLead.setBackgroundResource(R.drawable.shape_to_grouplead_bg);
//                    popupTogroupLead.setTextColor(getContext().getResources().getColor(R.color.white));
//                    popupTogroupLead.setText("成为团长");
//                }else{
//                    isChange= true;
//                    popupTogroupLead.setBackgroundResource(R.drawable.corner_eee_50);
//                    popupTogroupLead.setTextColor(getContext().getResources().getColor(R.color.color_999));
//                    popupTogroupLead.setText("暂无团长权限");
//
//                    if(pintuanBuyCantuanPopup==null){
//                        pintuanBuyCantuanPopup=new PintuanBuyCantuanPopup(getContext(),null,null);
//                    }
//                    pintuanBuyCantuanPopup.setPopupGravity(Gravity.BOTTOM);
//                    pintuanBuyCantuanPopup.showPopupWindow();
                dismiss();
                if (mPopupItemClickCallback != null) {
                    mPopupItemClickCallback.onSureCallback("");
                }
//                }
                break;
            default:
                break;
        }
    }

    public void setPopupItemClickCallback(PopupItemClickCallback popupItemClickCallback) {
        this.mPopupItemClickCallback = popupItemClickCallback;
    }


    /**
     * 设置文本
     */
    public void setPopupText(PintuanShopListResponBean pintuanShopListResponBean) {
        if (pintuanShopListResponBean != null) {
            popupTitle.setText(pintuanShopListResponBean.getGoods_name());
            popupNowPrice.setText(pintuanShopListResponBean.getSpe_price());
            popupYuanPrice.setText("￥" + pintuanShopListResponBean.getYuan_price());
            popupYuanPrice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); // 设置中划线并加清晰
            popupNum.setText("已团" + pintuanShopListResponBean.getOff_group_sum() + "件");
            ImageLoader.load(getContext(), pintuanShopListResponBean.getImage(), ivShopImage);
        }
    }
}
